package com.example.mywechatprogram.controller;

import com.example.mywechatprogram.entity.NewPassword;
import com.example.mywechatprogram.entity.Response;
import com.example.mywechatprogram.entity.User;
import com.example.mywechatprogram.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired
    UserService userService;
    @PostMapping("/User/signup")
    public Response addUser(@RequestBody User user){
        return userService.addUser(user);
    }
    @PostMapping("/User/login")
    public Response login(@RequestBody User user){
        return userService.login(user);
    }
    @PostMapping("/User/update")
    public Response update(@RequestBody NewPassword newPassword){
        return userService.update(newPassword);
    }
    @PostMapping("/User/delete")
    public Response delete(@RequestBody User user){return userService.delete(user);}
}
